package cloud.tianai.ram.policy.core.condition.impl;

import cloud.tianai.ram.policy.core.action.Action;
import cloud.tianai.ram.policy.core.condition.Condition;
import cloud.tianai.ram.policy.core.condition.ConditionHandler;
import cloud.tianai.ram.policy.core.condition.ConditionHandlerManager;

/**
 * @Author: 天爱有情
 * @date 2022/4/1 14:31
 * @Description 条件组合器 异或
 */
public class XorConditionHandler implements ConditionHandler {
    @Override
    public boolean match(Condition condition, ConditionHandlerManager conditionHandlerManager, Action action) {
        for (Condition child : condition.getChildren()) {
            if (!conditionHandlerManager.match(child, action).isAllow()) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String getType() {
        return "xor";
    }

    @Override
    public String getDescription() {
        return "异或";
    }
}
